package com.leeon.container.set;

import net.mindview.util.TextFile;

import java.util.*;

import static net.mindview.util.Print.print;

public class SetOfVowelChar {

    public static void main(String[] args) throws Exception {
        Set<String> words = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
        words.addAll(new TextFile("UniqueWords.java", "\\W+"));
        Set<Character> yuan = new TreeSet<Character>();
        Collections.addAll(yuan, 'a', 'o', 'e', 'i', 'u', 'A', 'O', 'E', 'I', 'U');
        Map<Character,Integer> countMap = new HashMap<Character, Integer>();
        for (String word : words) {
            for (char c : word.toCharArray()) {
                if(yuan.contains(c)){
                    if(countMap.containsKey(c)){
                        countMap.put(c,countMap.get(c) + 1);
                    }else{
                        countMap.put(c,1);
                    }
                }
            }
        }

        Set<Character> keySet = countMap.keySet();
        Iterator<Character> it = keySet.iterator();
        while (it.hasNext()){
            System.out.print("key = " + it.next() + " ");
        }
        print();
        System.out.println(countMap);
    }


}
